const int QueueSize=1000;
template<class T>
class CircleQueue
{
private:
    T data[QueueSize];
    int front;
    int rear;
public:
    CircleQueue(/* args */);
    ~CircleQueue();
    void EnQueue(T x);
    T DeQueue();
    T GetFront();
    int GetLength();
    bool Empty()
    {
        return front==rear?true:false;
    }
};
template<class T>
CircleQueue<T>::CircleQueue(/* args */)
{
    front=rear=0;
}
template<class T>
CircleQueue<T>::~CircleQueue()
{

}
template<class T>
void CircleQueue<T>::EnQueue(T x)
{
    if((rear+1)%QueueSize==front)throw"上溢";
    rear=(rear+1)%QueueSize;
    data[rear]=x; 
}
template<class T>
T CircleQueue<T>::DeQueue()
{
    if(rear==front)throw"下溢";
    front=(front+1)%QueueSize;
    return data[front];
}
template<class T>
T CircleQueue<T>::GetFront()
{
    if(rear==front)throw"下溢";
    return data[(front+1)%QueueSize];
}
template<class T>
int CircleQueue<T>::GetLength()
{
    return (rear-front+QueueSize)%QueueSize;
}